<extend name="./Common/View/EasyUI/form.html"/>
<block name="form">
    <div class="row">
        <div class="span12">
            <form method="post" id="pageForm" class="form-horizontal" action="Sys/Role/menu">
                <input name="role_id" value="{$role_id}" type="hidden">
                <input name="menu_id" id="menu_id" value="{implode(',', $menuList)}" type="hidden">
                <table class="table table-bordered table-striped">
                    <tbody>
                    <tr>
                        <th>菜单列表</th>
                    </tr>
                    <tr>
                        <td><ul id="menus"></ul></td>
                    </tr>
                    </tbody>
                </table>

            </form>
        </div>
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        window.layout = top.layout;
      $(function () {
         $('#menus').tree({
             url: app.api + 'Sys/Menu/app/role_id/{$role_id}',
             checkbox : true,
             idField : 'id',
             textField : 'title',
             onCheck : getSelection
         });
      });

        function getSelection() {
            var l = $('#menus').tree('getChecked');
            var ids = '';
            for (var i=0;i<l.length;i++){
                ids += ','+l[i].id;
            }
            if(ids.length > 1) ids = ids.substring(1);
            $('#menu_id').val(ids);
        }
    </script>
</block>